﻿using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint.WebControls;
using Slam.FieldTypes;

namespace SlamCms.SharePoint.FieldTypes
{
	public partial class FixedValueFieldControl : SlamFieldControl
	{
		protected Label lblFieldValue;

		protected override string DefaultTemplateName
		{
			get
			{
				return "SlamCMSFixedValueFieldControl";
			}
		}

		public override object Value
		{
			get
			{
				this.EnsureChildControls();

				return this.FixedValue;
			}
		}

		protected override void CreateChildControls()
		{
			if (Field == null)
				return;

			base.CreateChildControls();

			if (ControlMode == SPControlMode.Display)
				return;

			if (!base.IsFieldValueCached)
			{
				lblFieldValue = (Label)TemplateContainer.FindControl("lblFieldValue");
				lblFieldValue.Text = this.FixedValue;
			}
		}

		private string fixedValue;

		public string FixedValue
		{
			get { return fixedValue; }
			set { fixedValue = value; }
		}
	}
}
